﻿#pragma once

#include "Misc/CommonMacros.h"
#include "Containers/Any.h"
#include "Containers/Map.h"

// enable object have tags with any kind of reflectable type
class WHENGINE_API CTags
{

public:
    
    //添加标签或者更新标签值
    void UpdateTag(const CString& InTagKey,const CAny& InTag)
    {
        AllTags.Add(InTagKey,InTag);
    }

    void RemoveTag(const CString& InTagKey)
    {
        AllTags.Remove(InTagKey);
    }

    bool HasTag(const CString& InTagKey)
    {
        return AllTags.Contains(InTagKey);
    }

    //获取标签值，必须先使用HasTag检查是否存在
    CAny GetTag(const CString& InTagKey)
    {
        return AllTags[InTagKey];
    }

    //获取标签值，必须先使用HasTag检查是否存在
    template<typename T>
    T GetTagValue(const CString& InTagKey)
    {
        return AnyCast<T>(AllTags[InTagKey]);
    }
    

protected:
    TMap<CString,CAny> AllTags;

};